package com.mydesignpattern.beijing.singleton;

import com.sun.corba.se.spi.activation.InitialNameService;

public class SingleInnerClass {

    private static class InnerClass{
        private static SingleInnerClass single = new SingleInnerClass();
        public static SingleInnerClass getInstance(){
            return single;
        }
    }

    public static SingleInnerClass getInstance(){
        return InnerClass.getInstance();
    }

    public String toString(){
        return this.hashCode()+"";
    }

    public static void main(String[] args) {
        for (int i=0;i<2;i++){
            new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println("单例对象："+ SingleInnerClass.getInstance());
                }
            }).start();
        }
    }


}
